package com.stream.stream.sender;

import com.springcoud.domain.springcouddomain.User;
import com.stream.stream.Processor;
import com.stream.stream.Processor2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@EnableBinding(Processor2.class)
public class SenderController {
	@Autowired
	private Processor2 processor2;



	@RequestMapping("/send")
	public String sendMessage(){
		User user=new User();
		user.setId("1");
		user.setName("菜菜");
		processor2.output().send(MessageBuilder.withPayload(user).setHeader("msgId","1").build());
		return "success";
	}

	private static final <T> Message<T> message(T val) {
		return MessageBuilder.withPayload(val).build();
	}
}
